<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>宽带</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<link rel="stylesheet" href="https://static.91haoka.cn/vant.css" />
		<script src="https://static.91haoka.cn/vue.min.js"></script>
		<script src="https://static.91haoka.cn/vantall.js"></script>
		<script src="https://static.91haoka.cn/axios.min.js"></script>
		<link rel="stylesheet" type="text/css" href="https://static.91haoka.cn/all.css" />
	</head>
	<style type="text/css">
		* {
			box-sizing: border-box;
			font-family: 'PingFang SC';
			font-size: 14px;
		}

		[v-cloak] {
			display: none;
		}

		.top img {
			width: 100%;
			display: block;
		}

		.center {
			
		}

		

		.footer img {
			width: 100%;
			display: block;
		}

		.flex {
			display: flex;
		}
		
		.tishi{width: 1.5rem;}
		
		.taocan{ padding: 0.2rem; border-radius:5px; border:1px #eaeaea solid; text-align:center; margin-bottom:0.2rem;}
		.act{  border:1px #66b9ff solid;}
		
	</style>

	<body>
		<div id="app" style="background: #66b9ff; min-height: 100vh;" v-cloak>
			<div class="top">
				<div class="topimg">
					<img src="./top.jpg">
				</div>
			</div>



			<div class="center">
				<div style="background: #FFF; margin: 0px auto; width: 6.9rem; padding: 0.3rem; border-radius: 0.1rem; font-size: 0.28rem;">
					<div style="color: #000; font-size: 0.32rem; margin-bottom:0.3rem; font-weight: bold;">选择宽带套餐：</div>
					<div class="taocan" :class="xuanzhongdeindex == 1?'act':''" @click="xuanzhongdeindex = 1">山东电信1000M光纤宽带（2年）</div>
					<div class="taocan" :class="xuanzhongdeindex == 2?'act':''" @click="xuanzhongdeindex = 2">山东电信1000M光纤宽带（1年）</div>
					<div class="taocan" :class="xuanzhongdeindex == 3?'act':''" @click="xuanzhongdeindex = 3">山东电信300M光纤宽带（2年）</div>
					<div class="taocan" :class="xuanzhongdeindex == 4?'act':''" @click="xuanzhongdeindex = 4" style="margin-bottom: 0.5rem;">山东电信300M光纤宽带（1年）</div>
					<div style="color: #000; font-size: 0.32rem; margin-bottom:0.3rem; font-weight: bold;">填写安装信息：</div>
					<div class="flexc li" style="border-bottom: 1px #F1F3F5 solid; ">
						<div class="tishi">用户名称</div>
						<div class="neirong">
							<van-field v-model="id_name" placeholder="系统已加密，请放心填写" />
						</div>
					</div>
					<div class="flexc li" style="border-bottom: 1px #F1F3F5 solid; ">
						<div class="tishi">联系电话</div>
						<div class="neirong">
							<van-field v-model="mobile" placeholder="系统已加密，请放心填写" />
						</div>
					</div>
					<div class="flexc li" style="border-bottom: 1px #F1F3F5 solid; line-height:45px;">
						<div class="tishi">收货地址</div>
						<div class="neirong" @click="showPopup">
							<div class="where" style="padding-left: 16px; color:#969799;" v-if="shengshiqu == '点击选择所在地区'">{{shengshiqu}}
								<van-icon name="arrow" style="position: relative; top: 3px;" />
							</div>
							<div class="where" style="padding-left: 16px; " v-if="shengshiqu != '点击选择所在地区'">{{shengshiqu}}
								<van-icon name="arrow" style="position: relative; top: 3px;" />
							</div>
						</div>
					</div>
					<div class="flexc li" style="border-bottom: 1px #F1F3F5 solid;">
						<div class="tishi">详细地址</div>
						<div class="neirong">
							<van-field v-model="address" placeholder="请输入详细地址" />
						</div>
					</div>
					
					<div @click="tijiao" style="background:url(./anniu.png); background-size:cover; text-align:center; color:#fff; width:6.05rem; line-height:1.03rem; margin-top:0.5rem; font-size: 0.4rem;">提交办理</div>
				</div>

			</div>
			
			<div class="top">
				<div class="topimg">
					<img src="./top2.jpg">
				</div>
			</div>
			<van-popup v-model="show" position="bottom">
				<van-area :area-list="areaList" :columns-placeholder="['请选择', '请选择', '请选择']" @confirm="queren"
					cancel="quxiao" />
			</van-popup>
			
			
		</div>




		<script>
			var h = document.documentElement.clientWidth / 7.5 + 'px';
			document.documentElement.style.fontSize = h;


			new Vue({
				el: '#app',
				data: function() {
					return {
						xuanzhongdeindex:1,
						person: "",
						show2: false,
						radio: '1',
						id: 393520,
						share_id: 127837,
						sku: "电信顺星卡.",
						source_id: "",
						name: "",
						card: "",
						id_name: "",
						mobile: "",
						code: "",
						address: "",
						areaList: "",
						cardshow: false,
						show: false,
						shengshiqu: "点击选择所在地区",
						sheng: "",
						shi: "",
						qu: "",
						shengcode: "",
						shicode: "",
						qucode: "",
						yzm: "获取验证码",
						yzmnum: 60,
						yzmuse: false,
						tijiaouse: true,
						codego: false,
						weiyigo: true,
						guozhengtonggo: true,
						wxcode: "",
						links: "https://91haoka.com/api",
						scrollTopshow: false,
						tijiaoing: true,

						imgurl: "",
						total: 9.9,
						juliang: 0,
						urls: "",
						face_url:"",
						back_url:"",
						hand_url:"",
						is_need_photo:"",
						list:[
							{name:"山东电信1000M光纤宽带（2年）",sku:"DXKD-SD-1560-1000M-G59"},
							{name:"山东电信1000M光纤宽带（1年）",sku:"DXKD-SD-840-1000M-G59"},
							{name:"山东电信300M光纤宽带（2年）",sku:"DXKD-SD-840-300M-G59"},
							{name:"山东电信300M光纤宽带（1年）",sku:"DXKD-SD-480-300M-G59"}
						]
					}
				},
				async created() {

					if (!location.href.includes('91haoka')) {
						this.urls = '/apis'
					}
					
					var that = this
					let who = this.getUrlParam('id')
					//地址选择
					// https://static.91haoka.cn/areanew.json
					// https://static.91haoka.cn/tongyidiqu.json
					await axios.get("https://static.91haoka.cn/areanew.json")
						.then(function(response) {
							that.areaList = response.data
							that.areaList.province_list = {370000: "山东省"}
							
						})

					this.source_id = 'WEBAPP'+ parseInt(new Date().getTime()) + parseInt(Math.random()*100000000)
				},
				mounted() {
					
				},
				methods: {
					
					getUrlParam: function(name) {
						var query = window.location.search.substring(1);
						var vars = query.split("&");
						for (var i = 0; i < vars.length; i++) {
							var pair = vars[i].split("=");
							if (pair[0] == name) {
								return pair[1];
							}
						}
						return (false);
					},
					
					
					
					
					//弹出省市区
					showPopup: function() {
						this.show = true
					},
					//省市区确认
					queren: function(v) {
						if (!v[0].code || !v[1].code || !v[2].code) {
							vant.Toast('请完整选择省市区');
							return false
						}
						this.sheng = v[0].name
						this.shengcode = v[0].code
						this.shi = v[1].name
						this.shicode = v[1].code
						this.qu = v[2].name
						this.qucode = v[2].code
						this.shengshiqu = this.sheng + '  ' + this.shi + '  ' + this.qu
						this.show = false
					},
					//省市区取消
					quxiao: function() {
						this.show = false
					},

					tijiao: function() {
						if(!this.id_name || this.mobile.length != 11 || !this.address || !this.sheng){
							vant.Toast('请填写完整信息');
							return false
						}
						
						const data = {
							name:this.id_name,
							  source_id: this.source_id,
							  id_name: this.id_name,
							  mobile: this.mobile,
							  source: 'webapp',
							  sku: this.list[this.xuanzhongdeindex-1].sku,
							  province: this.sheng,
							  city: this.shi,
							  district: this.qu,
							  province_code: '',
							  city_code: '',
							  district_code: '',
							  address: this.address,
							  pretty_number:'',
							  // product_id: this.currentId,
							  share_id: 127837,
							  clickid:this.getUrlParam('clickid'),
							  creativeid:this.getUrlParam('creativeid'),
							  creativetype:this.getUrlParam('creativetype'),
							  adid:this.getUrlParam('adid')
						};
						
						

						axios.post(this.urls + "/api/plan-market/order/for-web/purchase2", data)
							.then(function(response) {
								if (response.data.msg.code == 0) {
									location.href="./success.html"
								} else {
									vant.Toast(response.data.msg.info);
								}

							})
					}
				}
			});
		</script>
	</body>

</html>
